/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/10/14-下午4:50
 * Since  :   1.0
 * Version:   1.0
 */


public class DFS {
    public static void main(String[] args) {
        int nums[][]={
            {0,1,1,0,1},
            {1,0,1,1,0},
            {1,1,0,0,0},
            {0,1,0,0,1},
            {1,0,0,1,0}
        };
        Boolean[] visited = new Boolean[nums.length];
       findDfs(nums,visited,0);


    }

    public static void findDfs(int [][]nums,Boolean[]visited ,int start){
        if (!visited[start]){
            visited[start]=true;
            System.out.println(start);
        }

        for (int i=start;i<nums.length;i++){
            if (!visited[i]&&nums[start][i]==1){
                findDfs(nums,visited,i);
            }
        }


    }



}
